using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Avalonia.Controls;
using MsBox.Avalonia;
using MsBox.Avalonia.Dto;
using MsBox.Avalonia.Enums;
using MsBox.Avalonia.Models;

namespace Avalonia.MusicStore.Commons;

public static class DialogEx
{
    public static async Task<string> OpenDialog(string content, string title = null)
    {
        var box = MessageBoxManager.GetMessageBoxCustom(new MessageBoxCustomParams
        {
            ButtonDefinitions =
            [
                new ButtonDefinition { Name = "取消", IsCancel = true },
                new ButtonDefinition { Name = "确定" },
            ],
            ContentTitle = title ?? "提示",
            ContentMessage = content,
            WindowStartupLocation = WindowStartupLocation.CenterOwner,
            Icon = Icon.Question,
            CanResize = false,
            MaxWidth = 500,
            MaxHeight = 800,
            SizeToContent = SizeToContent.WidthAndHeight,
            ShowInCenter = true,
            Topmost = false
        });
        var result = await box.ShowAsync();
        return result;
    }
}